#ifndef CHATWIDGET_H
#define CHATWIDGET_H

#include <QWidget>
#include <QLineEdit>
#include <QPushButton>
#include <QVBoxLayout>
#include <QTextEdit>
#include <QTcpSocket>
#include <QDebug>

class ChatWidget : public QWidget {
    Q_OBJECT

public:
    explicit ChatWidget(const QString &role, QWidget *parent = nullptr);

private slots:
    void onSendClicked();
    void on_readyRead();

private:
    QLineEdit *inputField;
    QTextEdit *chatDisplay;
    QPushButton *sendButton;
    QTcpSocket *socket;

    QString role;  // 角色 (医生或病人)
    void sendMessage(const QString &message);
};

#endif // CHATWIDGET_H
